package main

import (
	"fmt"
	"strconv"
	"strings"
)

type IPAddr [4]byte

func (ip IPAddr) String() string {
	x := make([]string, len(ip))
	//x := make([]string, 0)
	for index, value := range ip {
		x[index] = strconv.Itoa(int(value))
		//for _, value := range ip {
		//x = append(x, strconv.Itoa(int(value)))
		//	https://stackoverflow.com/questions/31220421/convert-a-byte-to-a-string-in-go
	}
	return strings.Join(x, ".")
}

func main() {
	hosts := map[string]IPAddr{
		"loopback":  {127, 0, 0, 1},
		"googleDNS": {8, 8, 8, 8},
	}

	for name, ip := range hosts {
		fmt.Printf("%v: %v\n", name, ip)
	}
}
